#ifndef JPROJECTWIDGET_H
#define JPROJECTWIDGET_H

#include <QTreeWidget>
#include <QDomDocument>
#include <QHash>

class JProjectWidget : public QTreeWidget
{
	Q_OBJECT

public:
	JProjectWidget(QWidget *parent);
	~JProjectWidget();

	void setCurrentProject(const QString& name);
	bool restoreFromFile(const QString& filename);
	bool saveToFile(const QString& filename);

	bool read(QIODevice *device);
	bool write(QIODevice *device);

private slots:
	void contextMenu(const QPoint &pt);
	void loadModel();
	void loadKinematics();
	
	void updateDomElement(QTreeWidgetItem *item, int column);

private:
	QString strippedName(const QString &fullFileName);

	void parseFolderElement(const QDomElement &element, QTreeWidgetItem *parentItem = 0);
	QTreeWidgetItem *createItem(const QDomElement &element, QTreeWidgetItem *parentItem = 0);

	QDomDocument domDocument;
	QHash<QTreeWidgetItem *, QDomElement> domElementForItem;

	QTreeWidgetItem* m_pRoot;
	QString m_CurrentProjectName;
};

#endif // JPROJECTWIDGET_H
